package cn.dyw.shop.model;
// Generated 2018-5-12 12:17:09 by Hibernate Tools 5.1.0.Alpha1

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * OrderItem generated by hbm2java
 */
@JsonIgnoreProperties(value={"handler", "hibernateLazyInitializer", "fieldHandler"})
@Entity
@Table(name = "order_item", catalog = "shop")
public class OrderItem implements java.io.Serializable {

	private Integer id;
	private Goods goods;
	private Order order;
	private BigDecimal price;
	private Integer num;
	private BigDecimal totalPrice;
	private Boolean comment;
	private Integer refund;
	private List<Comment> comments = new ArrayList<>(0);

	public OrderItem() {
	}

	public OrderItem(Goods goods, Order order, BigDecimal price, Integer num, BigDecimal totalPrice, Boolean comment,
					 List<Comment> comments, Integer refund) {
		this.goods = goods;
		this.order = order;
		this.price = price;
		this.num = num;
		this.totalPrice = totalPrice;
		this.refund = refund;
		this.comment = comment;
		this.comments = comments;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)

	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@JsonManagedReference
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "good_id")
	public Goods getGoods() {
		return this.goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	@JsonBackReference
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "order_id")
	public Order getOrder() {
		return this.order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	@Column(name = "price", precision = 8)
	public BigDecimal getPrice() {
		return this.price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	@Column(name = "num")
	public Integer getNum() {
		return this.num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	@Column(name = "total_price", precision = 8)
	public BigDecimal getTotalPrice() {
		return this.totalPrice;
	}

	public void setTotalPrice(BigDecimal totalPrice) {
		this.totalPrice = totalPrice;
	}

	@Column(name = "comment")
	public Boolean getComment() {
		return this.comment;
	}

	public void setComment(Boolean comment) {
		this.comment = comment;
	}

    @Column(name = "refund")
    public Integer getRefund() {
        return refund;
    }

    public void setRefund(Integer refund) {
        this.refund = refund;
    }

	@JsonManagedReference
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "orderItem")
	public List<Comment> getComments() {
		return this.comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

}
